package com.dongwu.manager.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.dongwu.common.dao.BaseDao;
import com.dongwu.manager.entity.Advertising;

@Repository
public interface AdvertisingDao  extends BaseDao<Advertising, String> {

	@Query(value="select count(*) from advertising where userid = ?1", nativeQuery=true)//原生sql语句
	public Long countByUserid(String userid);
	
	//分类查询广告
	@Query(value="SELECT * FROM advertising where "
			+ "id in (SELECT advertisingid from device_ads_record where deviceid = ?1 and `status` = ?2) "
			+ "AND "
			+ "adsclassify_id = ?3", nativeQuery=true)//原生sql语句
	public List<Advertising> getAdsForClassify(String deviceId, Integer status,String classifyId);
}
